package com.lxq.market.filter;

import com.lxq.market.util.SessionSignIn;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter("/update/*")
public class UpdateFilter extends HttpFilter {
    SessionSignIn sign=SessionSignIn.getInstance();

    @Override
    protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {
        if (sign.find(req.getSession().getId())==null) {
            res.setStatus(HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED);
            return;
        }
        chain.doFilter(req,res);
    }
}
